package com.photoeditor.demo.model.bean.stash;

import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.graphics.RectF;

import com.common.base.ComponentContext;
import com.photoeditor.R;
import com.photoeditor.demo.model.image.collage.templet.Line;
import com.photoeditor.demo.model.image.collage.util.MathUtil;
import com.photoeditor.demo.model.image.emoji.LocalStickerData;
import com.photoeditor.demo.model.bean.EmojiBean;
import com.photoeditor.demo.ui.widget.stash.container.ContainerView;

import static com.photoeditor.demo.model.bean.EditEmojiBean.RADIUS;

/**
 * Created by Administrator on 2017/6/23 0023.
 */

public class StickerBean implements ContainerBean{

    /**
     * Emoji的最小大小
     */
    public final static int SMALLEST_SIZE = ComponentContext.getContext().getResources().getDimensionPixelSize(R.dimen.scale_smallest_size);


    /**
     * Emoji的大小
     */
    public final int EMOJI_WIDTH;
    public final int EMOJI_HEIGHT;

    /**
     * 当前Bean的Rect
     */
    private RectF mRect;

    /**
     * 用于保存旋转的角度
     */
    private float mDegree;
    private float mRealDegree;

    /**
     * 用于点击时 点击位置的映射
     */
    private Matrix mMatrix ;

    /**
     * 是否正被点击
     */
    private boolean mIsTouch;

    private float mMaxSize;

    /**
     * 操作按钮的Rect
     */
    private RectF mButtonRect;

    /**
     * 操作按钮的Rect
     */
    private RectF mDeleteRect;

    /**
     * 设置按钮的Rect
     */
    private RectF mSettingRect;

    private RectF mLeftOperationRect;
    private RectF mTopOperationRect;
    private RectF mRightOperationRect;
    private RectF mBottomOperationRect;

    /**
     * emojiId
     */
    private EmojiBean mEmojiBean;

    private RectF mLastRectBeforeScale = new RectF();

    public RectF getLastRectBeforeScale() {
        return mLastRectBeforeScale;
    }

    @Override
    public Bitmap getBitmap() {
        return LocalStickerData.getInstance().getBitmap(mEmojiBean);
    }

    @Override
    public void onDestroy() {
//        LocalStickerData.getInstance().getBitmap(mEmojiBean).recycle();
    }

    /**
     * @param mDrawableRect
     * @param bean
     */
    public StickerBean(RectF mDrawableRect, EmojiBean bean){
        mEmojiBean = bean;
        mDegree = 0;
        mRealDegree = 0;
        mMatrix = new Matrix();
        mRect = new RectF();
        mButtonRect = new RectF();
        mDeleteRect = new RectF();
        mSettingRect = new RectF();
        mLeftOperationRect = new RectF();
        mTopOperationRect = new RectF();
        mRightOperationRect = new RectF();
        mBottomOperationRect = new RectF();
        mIsTouch = false;
        EMOJI_WIDTH = bean.getEditEmojiWidth();
        EMOJI_HEIGHT = bean.getEditEmojiHeight();
        init(mDrawableRect);
    }

    public StickerBean(EmojiBean bean, RectF rectF, float degree){
        mEmojiBean = bean;
        mDegree = degree;
        mRealDegree = degree;
        mMatrix = new Matrix();
        mRect = new RectF();
        mButtonRect = new RectF();
        mDeleteRect = new RectF();
        mSettingRect = new RectF();
        mLeftOperationRect = new RectF();
        mTopOperationRect = new RectF();
        mRightOperationRect = new RectF();
        mBottomOperationRect = new RectF();
        mRect.set(rectF);
        countOtherRect();
        mIsTouch = false;
        EMOJI_WIDTH = bean.getEditEmojiWidth();
        EMOJI_HEIGHT = bean.getEditEmojiHeight();
        mLastRectBeforeScale.set(mRect);
        mMaxSize = EMOJI_WIDTH * 20;
    }

    private void init(RectF mDrawableRect){
        float dx = (mDrawableRect.width() - EMOJI_WIDTH) / 2;
        float dy = (mDrawableRect.height() - EMOJI_HEIGHT) / 2;
        mRect.left = mDrawableRect.left + dx;
        mRect.top = mDrawableRect.top + dy;
        mRect.right = mDrawableRect.right - dx;
        mRect.bottom = mDrawableRect.bottom - dy;
        mLastRectBeforeScale.set(mRect);
        mMaxSize = mRect.width()*20;

        countOtherRect();
    }

    @Override
    public void setIsTouch(boolean isTouch) {
        this.mIsTouch = isTouch;
    }

    @Override
    public boolean isTouch() {
        return mIsTouch;
    }

    @Override
    public Matrix getMatrix() {
        mMatrix.setRotate(-mDegree, mRect.centerX(), mRect.centerY());
        return mMatrix;
    }

    @Override
    public RectF getRect() {
        return mRect;
    }

    @Override
    public RectF getButtonRect() {
        return mButtonRect;
    }

    @Override
    public RectF getSettingRect() {
        return mSettingRect;
    }

    @Override
    public RectF getDeleteRect() {
        return mDeleteRect;
    }

    @Override
    public RectF getLeftOperationRect() {
        return mLeftOperationRect;
    }

    @Override
    public RectF getTopOperationRect() {
        return mTopOperationRect;
    }

    @Override
    public RectF getRightOperationRect() {
        return mRightOperationRect;
    }

    @Override
    public RectF getBottomOperationRect() {
        return mBottomOperationRect;
    }

    @Override
    public void operationLeft(float dx) {
        float leftTopPoint[] = new float[]{mRect.left, mRect.top};
        float rightTopPoint[] = new float[]{mRect.right, mRect.top};
        float leftbottomPoint[] = new float[]{mRect.left, mRect.bottom};
        float rightBottomPoint[] = new float[]{mRect.right, mRect.bottom};

        float leftTopPointMap[] = new float[2];
        float rightTopPointMap[] = new float[2];
        float leftbottomPointMap[] = new float[2];
        float rightBottomPointMap[] = new float[2];
        Matrix m1 = new Matrix();
        m1.postRotate(getDegree(), mRect.centerX(), mRect.centerY());
        m1.mapPoints(leftTopPointMap, leftTopPoint);
        m1.mapPoints(rightTopPointMap, rightTopPoint);
        m1.mapPoints(leftbottomPointMap, leftbottomPoint);
        m1.mapPoints(rightBottomPointMap, rightBottomPoint);

        Line line = new Line(leftTopPointMap[0], -leftTopPointMap[1], rightTopPointMap[0], -rightTopPointMap[1]);
        double x, y;
        if (line.isHrizontal()) {
            x = dx;
            y = 0;
        } else if (line.isVertical()) {
            x = 0;
            y = dx;
        } else {
            int location1 = MathUtil.getLocation(leftTopPointMap[0] - rightTopPointMap[0], leftTopPointMap[1] - rightTopPointMap[1]);
            double degree1 = MathUtil.getDegreeFromX(line, location1);
            if (degree1 < 90) {
                double radians = Math.toRadians(degree1);
                if (dx < 0) {
                    x = -dx * Math.cos(radians);
                    y = dx * Math.sin(radians);
                } else {
                    x = -dx * Math.cos(radians);
                    y = dx * Math.sin(radians);
                }
            } else if (degree1 < 180) {
                double radians = Math.toRadians(180 - degree1);
                if (dx < 0) {
                    x = dx * Math.cos(radians);
                    y = dx * Math.sin(radians);
                } else {
                    x = dx * Math.cos(radians);
                    y = dx * Math.sin(radians);
                }
            } else if (degree1 < 270) {
                double radians = Math.toRadians(270 - degree1);
                if (dx < 0) {
                    x = dx * Math.sin(radians);
                    y = -dx * Math.cos(radians);
                } else {
                    x = dx * Math.sin(radians);
                    y = -dx * Math.cos(radians);
                }
            } else {
                double radians = Math.toRadians(360 - degree1);
                if (dx < 0) {
                    x = -dx * Math.cos(radians);
                    y = -dx * Math.sin(radians);
                } else {
                    x = -dx * Math.cos(radians);
                    y = -dx * Math.sin(radians);
                }
            }
        }
        float leftTopPointMapResult[] = new float[2];
        float leftbottomPointMapResult[] = new float[2];
        leftTopPointMapResult[0] = leftTopPointMap[0] + (float) x;
        leftTopPointMapResult[1] = leftTopPointMap[1] + (float) y;
        leftbottomPointMapResult[0] = leftbottomPointMap[0] + (float) x;
        leftbottomPointMapResult[1] = leftbottomPointMap[1] + (float) y;

        RectF rectF = MathUtil.point2RectF(leftTopPointMapResult, leftbottomPointMapResult, rightTopPointMap, rightBottomPointMap);
        m1.reset();
        m1.postRotate(-getDegree(), rectF.centerX(), rectF.centerY());
        m1.mapPoints(leftTopPointMapResult);
        m1.mapPoints(leftbottomPointMapResult);
        m1.mapPoints(rightTopPointMap);
        m1.mapPoints(rightBottomPointMap);
        rectF = MathUtil.point2RectF(leftTopPointMapResult, leftbottomPointMapResult, rightTopPointMap, rightBottomPointMap);

        if (rectF.width() >= SMALLEST_SIZE) {
            mRect = new RectF(rectF);
            mRect.left = Math.min(mRect.left, mRect.right);
            countOtherRect();
        }
    }

    @Override
    public void operationRight(float dx) {
        float leftTopPoint[] = new float[]{mRect.left, mRect.top};
        float rightTopPoint[] = new float[]{mRect.right, mRect.top};
        float leftbottomPoint[] = new float[]{mRect.left, mRect.bottom};
        float rightBottomPoint[] = new float[]{mRect.right, mRect.bottom};

        float leftTopPointMap[] = new float[2];
        float rightTopPointMap[] = new float[2];
        float leftbottomPointMap[] = new float[2];
        float rightBottomPointMap[] = new float[2];
        Matrix m1 = new Matrix();
        m1.postRotate(getDegree(), mRect.centerX(), mRect.centerY());
        m1.mapPoints(leftTopPointMap, leftTopPoint);//计算map后的点
        m1.mapPoints(rightTopPointMap, rightTopPoint);
        m1.mapPoints(leftbottomPointMap, leftbottomPoint);
        m1.mapPoints(rightBottomPointMap, rightBottomPoint);

        Line line = new Line(leftTopPointMap[0], -leftTopPointMap[1], rightTopPointMap[0], -rightTopPointMap[1]);
        double x, y;
        if (line.isHrizontal()) {
            x = dx;
            y = 0;
        } else if (line.isVertical()) {
            x = 0;
            y = dx;
        } else {
            int location1 = MathUtil.getLocation(rightTopPointMap[0] - leftTopPointMap[0], rightTopPointMap[1] - leftTopPointMap[1]);
            double degree1 = MathUtil.getDegreeFromX(line, location1);
            if (degree1 < 90) {
                double radians = Math.toRadians(degree1);
                if (dx < 0) {
                    x = dx * Math.cos(radians);
                    y = -dx * Math.sin(radians);
                } else {
                    x = dx * Math.cos(radians);
                    y = -dx * Math.sin(radians);
                }
            } else if (degree1 < 180) {
                double radians = Math.toRadians(180 - degree1);
                if (dx < 0) {
                    x = -dx * Math.cos(radians);
                    y = -dx * Math.sin(radians);
                } else {
                    x = -dx * Math.cos(radians);
                    y = -dx * Math.sin(radians);
                }
            } else if (degree1 < 270) {
                double radians = Math.toRadians(270 - degree1);
                if (dx < 0) {
                    x = -dx * Math.sin(radians);
                    y = dx * Math.cos(radians);
                } else {
                    x = -dx * Math.sin(radians);
                    y = dx * Math.cos(radians);
                }
            } else {
                double radians = Math.toRadians(360 - degree1);
                if (dx < 0) {
                    x = dx * Math.cos(radians);
                    y = dx * Math.sin(radians);
                } else {
                    x = dx * Math.cos(radians);
                    y = dx * Math.sin(radians);
                }
            }
        }
        float rightTopPointMapResult[] = new float[2];
        float rightbottomPointMapResult[] = new float[2];
        rightTopPointMapResult[0] = rightTopPointMap[0] + (float) x;
        rightTopPointMapResult[1] = rightTopPointMap[1] + (float) y;
        rightbottomPointMapResult[0] = rightBottomPointMap[0] + (float) x;
        rightbottomPointMapResult[1] = rightBottomPointMap[1] + (float) y;

        RectF rectF = MathUtil.point2RectF(leftTopPointMap, leftbottomPointMap, rightTopPointMapResult, rightbottomPointMapResult);
        m1.reset();
        m1.postRotate(-getDegree(), rectF.centerX(), rectF.centerY());
        m1.mapPoints(leftTopPointMap);
        m1.mapPoints(leftbottomPointMap);
        m1.mapPoints(rightTopPointMapResult);
        m1.mapPoints(rightbottomPointMapResult);
        rectF = MathUtil.point2RectF(leftTopPointMap, leftbottomPointMap, rightTopPointMapResult, rightbottomPointMapResult);

        if (rectF.width() >= SMALLEST_SIZE) {
            mRect = new RectF(rectF);
            mRect.left = Math.min(mRect.left, mRect.right);
            countOtherRect();
        }
    }

    @Override
    public void operationTop(float dy) {
        float leftTopPoint[] = new float[]{mRect.left, mRect.top};
        float rightTopPoint[] = new float[]{mRect.right, mRect.top};
        float leftbottomPoint[] = new float[]{mRect.left, mRect.bottom};
        float rightBottomPoint[] = new float[]{mRect.right, mRect.bottom};

        float leftTopPointMap[] = new float[2];
        float rightTopPointMap[] = new float[2];
        float leftbottomPointMap[] = new float[2];
        float rightBottomPointMap[] = new float[2];
        Matrix m1 = new Matrix();
        m1.postRotate(getDegree(), mRect.centerX(), mRect.centerY());
        m1.mapPoints(leftTopPointMap, leftTopPoint);//计算map后的点
        m1.mapPoints(rightTopPointMap, rightTopPoint);
        m1.mapPoints(leftbottomPointMap, leftbottomPoint);
        m1.mapPoints(rightBottomPointMap, rightBottomPoint);

        Line line = new Line(leftTopPointMap[0], -leftTopPointMap[1], leftbottomPointMap[0], -leftbottomPointMap[1]);
        double x, y;
        if (line.isHrizontal()) {
            x = dy;
            y = 0;
        } else if (line.isVertical()) {
            x = 0;
            y = dy;
        } else {
            int location1 = MathUtil.getLocation(leftTopPointMap[0] - leftbottomPointMap[0], leftTopPointMap[1] - leftbottomPointMap[1]);
            double degree1 = MathUtil.getDegreeFromX(line, location1);
            if (degree1 < 90) {
                double radians = Math.toRadians(degree1);
                if (dy < 0) {
                    x = -dy * Math.cos(radians);
                    y = dy * Math.sin(radians);
                } else {
                    x = -dy * Math.cos(radians);
                    y = dy * Math.sin(radians);
                }
            } else if (degree1 < 180) {
                double radians = Math.toRadians(180 - degree1);
                if (dy < 0) {
                    x = dy * Math.cos(radians);
                    y = dy * Math.sin(radians);
                } else {
                    x = dy * Math.cos(radians);
                    y = dy * Math.sin(radians);
                }
            } else if (degree1 < 270) {
                double radians = Math.toRadians(270 - degree1);
                if (dy < 0) {
                    x = dy * Math.sin(radians);
                    y = -dy * Math.cos(radians);
                } else {
                    x = dy * Math.sin(radians);
                    y = -dy * Math.cos(radians);
                }
            } else {
                double radians = Math.toRadians(360 - degree1);
                if (dy < 0) {
                    x = -dy * Math.cos(radians);
                    y = -dy * Math.sin(radians);
                } else {
                    x = -dy * Math.cos(radians);
                    y = -dy * Math.sin(radians);
                }
            }
        }
        float leftTopPointMapResult[] = new float[2];
        float rightTopPointMapResult[] = new float[2];
        leftTopPointMapResult[0] = leftTopPointMap[0] + (float) x;
        leftTopPointMapResult[1] = leftTopPointMap[1] + (float) y;
        rightTopPointMapResult[0] = rightTopPointMap[0] + (float) x;
        rightTopPointMapResult[1] = rightTopPointMap[1] + (float) y;

        RectF rectF = MathUtil.point2RectF(leftTopPointMapResult, leftbottomPointMap, rightTopPointMapResult, rightBottomPointMap);
        m1.reset();
        m1.postRotate(-getDegree(), rectF.centerX(), rectF.centerY());
        m1.mapPoints(leftTopPointMapResult);
        m1.mapPoints(leftbottomPointMap);
        m1.mapPoints(rightTopPointMapResult);
        m1.mapPoints(rightBottomPointMap);
        rectF = MathUtil.point2RectF(leftTopPointMapResult, leftbottomPointMap, rightTopPointMapResult, rightBottomPointMap);

        if (rectF.width() >= SMALLEST_SIZE) {
            mRect = new RectF(rectF);
            mRect.left = Math.min(mRect.left, mRect.right);
            countOtherRect();
        }
    }

    @Override
    public void operationBottom(float dy) {
        float leftTopPoint[] = new float[]{mRect.left, mRect.top};
        float rightTopPoint[] = new float[]{mRect.right, mRect.top};
        float leftbottomPoint[] = new float[]{mRect.left, mRect.bottom};
        float rightBottomPoint[] = new float[]{mRect.right, mRect.bottom};

        float leftTopPointMap[] = new float[2];
        float rightTopPointMap[] = new float[2];
        float leftbottomPointMap[] = new float[2];
        float rightBottomPointMap[] = new float[2];

        Matrix m1 = new Matrix();
        m1.postRotate(getDegree(), mRect.centerX(), mRect.centerY());
        m1.mapPoints(leftTopPointMap, leftTopPoint);//计算map后的点
        m1.mapPoints(rightTopPointMap, rightTopPoint);
        m1.mapPoints(leftbottomPointMap, leftbottomPoint);
        m1.mapPoints(rightBottomPointMap, rightBottomPoint);

        Line line = new Line(leftbottomPointMap[0], -leftbottomPointMap[1], leftTopPointMap[0], -leftTopPointMap[1]);
        double x, y;
        if (line.isHrizontal()) {
            x = dy;
            y = 0;
        } else if (line.isVertical()) {
            x = 0;
            y = dy;
        } else {
            int location1 = MathUtil.getLocation(leftbottomPointMap[0] - leftTopPointMap[0], leftbottomPointMap[1] - leftTopPointMap[1]);
            double degree1 = MathUtil.getDegreeFromX(line, location1);
            if (degree1 < 90) {
                double radians = Math.toRadians(degree1);
                if (dy < 0) {
                    x = dy * Math.cos(radians);
                    y = -dy * Math.sin(radians);
                } else {
                    x = dy * Math.cos(radians);
                    y = -dy * Math.sin(radians);
                }
            } else if (degree1 < 180) {
                double radians = Math.toRadians(180 - degree1);
                if (dy < 0) {
                    x = -dy * Math.cos(radians);
                    y = -dy * Math.sin(radians);
                } else {
                    x = -dy * Math.cos(radians);
                    y = -dy * Math.sin(radians);
                }
            } else if (degree1 < 270) {
                double radians = Math.toRadians(270 - degree1);
                if (dy < 0) {
                    x = -dy * Math.sin(radians);
                    y = dy * Math.cos(radians);
                } else {
                    x = -dy * Math.sin(radians);
                    y = dy * Math.cos(radians);
                }
            } else {
                double radians = Math.toRadians(360 - degree1);
                if (dy < 0) {
                    x = dy * Math.cos(radians);
                    y = dy * Math.sin(radians);
                } else {
                    x = dy * Math.cos(radians);
                    y = dy * Math.sin(radians);
                }
            }
        }
        float leftBottomPointMapResult[] = new float[2];
        float rightbottomPointMapResult[] = new float[2];
        leftBottomPointMapResult[0] = leftbottomPointMap[0] + (float) x;
        leftBottomPointMapResult[1] = leftbottomPointMap[1] + (float) y;
        rightbottomPointMapResult[0] = rightBottomPointMap[0] + (float) x;
        rightbottomPointMapResult[1] = rightBottomPointMap[1] + (float) y;

        RectF rectF = MathUtil.point2RectF(leftTopPointMap, leftBottomPointMapResult, rightTopPointMap, rightbottomPointMapResult);
        m1.reset();
        m1.postRotate(-getDegree(), rectF.centerX(), rectF.centerY());
        m1.mapPoints(leftTopPointMap);
        m1.mapPoints(leftBottomPointMapResult);
        m1.mapPoints(rightTopPointMap);
        m1.mapPoints(rightbottomPointMapResult);
        rectF = MathUtil.point2RectF(leftTopPointMap, leftBottomPointMapResult, rightTopPointMap, rightbottomPointMapResult);

        if (rectF.width() >= SMALLEST_SIZE) {
            mRect = new RectF(rectF);
            mRect.left = Math.min(mRect.left, mRect.right);
            countOtherRect();
        }
    }

    @Override
    public void setDegree(float degree) {
        mRealDegree += degree;
        float remain = mRealDegree % 90;
        if(Math.abs(remain) >= 0 && Math.abs(remain) < 3) {
            this.mDegree = mRealDegree - remain;
        } else if(Math.abs(remain) > 87) {
            if (remain > 0) {
                this.mDegree = mRealDegree + 90 - remain;
            } else {
                this.mDegree = mRealDegree - 90 - remain;
            }
        } else {
            mDegree = mRealDegree;
        }
    }

    @Override
    public float getDegree() {
        return mDegree;
    }

    @Override
    public void dealScaleAndRotation(float downX, float downY, float nowX, float nowY) {
        float px = mRect.centerX();
        float py = mRect.centerY();

        float x1 = downX - px;
        float y1 = downY - py;

        float x2 = nowX - px;
        float y2 = nowY - py;

        float scale = (float) (Math.sqrt(x2 * x2 + y2 * y2) / Math.sqrt(x1 * x1 + y1 * y1));

        double degree1 = MathUtil.getDegree(px, py, downX, downY, px + 1, py);

        double degree2 = MathUtil.getDegree(px, py, nowX, nowY, px + 1, py);

        int location1 = MathUtil.getLocation(x1, y1);
        int location2 = MathUtil.getLocation(x2, y2);

        /**
         * 这里是以px, py作为原点   如果是一二象限则 是逆时针旋转  取负值
         *
         * 如果是三四象限则顺时针角度比较小 取正值
         */
        if (location2 == 1 || location2 == 2) {
            degree2 = -degree2;
        }

        if (location1 == 1 || location1 == 2) {
            degree1 = -degree1;
        }

        double degree = degree2 - degree1;

        setScale(scale);
        setDegree((float) degree);
    }

    @Override
    public void setScale(float scale) {
        Matrix m = new Matrix();
        m.setScale(scale, scale, mRect.centerX(), mRect.centerY());
        RectF rect = new RectF();
        m.mapRect(rect, mRect);
        if(rect.width() >= SMALLEST_SIZE && rect.width() <= mMaxSize) {
            mRect = rect;
            countOtherRect();
            mLastRectBeforeScale.set(mRect);
        }
    }

    @Override
    public void scaleTo(RectF lastRectF, float scale) {
        Matrix m = new Matrix();
        m.setScale(scale, scale, mRect.centerX(), mRect.centerY());
        m.mapRect(mRect, lastRectF);

        countOtherRect();
    }

    @Override
    public void setLastMatrix(Matrix matrix) {

    }

    @Override
    public void doScaleMove(RectF baseRect, RectF supperRect, Matrix matrix, Matrix cacheMatrix, RectF viewRect) {

    }

    @Override
    public void setDegreeDirect(float degree) {

    }

    @Override
    public void setFlip(boolean horizontal, float value) {

    }

    @Override
    public float getFlipX() {
        return 0;
    }

    @Override
    public float getFlipY() {
        return 0;
    }

    @Override
    public void move(float dx, float dy) {
        mRect.offset(dx, dy);
        mButtonRect.offset(dx, dy);
        mDeleteRect.offset(dx, dy);
        mSettingRect.offset(dx, dy);
        mLeftOperationRect.offset(dx, dy);
        mRightOperationRect.offset(dx, dy);
        mTopOperationRect.offset(dx, dy);
        mBottomOperationRect.offset(dx, dy);

        mLastRectBeforeScale.offset(dx, dy);
    }

    @Override
    public void moveTo(RectF lastRectF, float dx, float dy) {
        mRect.left = lastRectF.left - dx;
        mRect.right = lastRectF.right - dx;
        mRect.top = lastRectF.top - dy;
        mRect.bottom = lastRectF.bottom - dy;

        countOtherRect();
    }

    @Override
    public int getType() {
        return ContainerView.BEAN_TYPE_STICKER;
    }

    public Object getBean() {
        return mEmojiBean;
    }

    /**
     * 计算其他辅助juzhen
     */
    private void countOtherRect() {
        mButtonRect.left = mRect.right - RADIUS;
        mButtonRect.top = mRect.bottom - RADIUS;
        mButtonRect.right = mRect.right + RADIUS;
        mButtonRect.bottom = mRect.bottom + RADIUS;

        mSettingRect.left = mRect.left - RADIUS;
        mSettingRect.top = mRect.bottom - RADIUS;
        mSettingRect.right = mRect.left + RADIUS;
        mSettingRect.bottom = mRect.bottom + RADIUS;

        mDeleteRect.left = mRect.left - RADIUS;
        mDeleteRect.top = mRect.top - RADIUS;
        mDeleteRect.right = mRect.left + RADIUS;
        mDeleteRect.bottom = mRect.top + RADIUS;

        mLeftOperationRect.left = mRect.left - RADIUS;
        mLeftOperationRect.top = (mRect.top + mRect.bottom) / 2 - RADIUS;
        mLeftOperationRect.right = mRect.left + RADIUS;
        mLeftOperationRect.bottom = (mRect.top + mRect.bottom) / 2 + RADIUS;

        mRightOperationRect.left = mRect.right - RADIUS;
        mRightOperationRect.top = (mRect.top + mRect.bottom) / 2 - RADIUS;
        mRightOperationRect.right = mRect.right + RADIUS;
        mRightOperationRect.bottom = (mRect.top + mRect.bottom) / 2 + RADIUS;

        mTopOperationRect.left = (mRect.left + mRect.right) / 2 - RADIUS;
        mTopOperationRect.top = mRect.top - RADIUS;
        mTopOperationRect.right = (mRect.left + mRect.right) / 2 + RADIUS;
        mTopOperationRect.bottom = mRect.top + RADIUS;

        mBottomOperationRect.left = (mRect.left + mRect.right) / 2 - RADIUS;
        mBottomOperationRect.top = mRect.bottom - RADIUS;
        mBottomOperationRect.right = (mRect.left + mRect.right) / 2 + RADIUS;
        mBottomOperationRect.bottom = mRect.bottom + RADIUS;
    }
}
